package com.example.demo.service;
import com.example.demo.dao.HomeworkDao;
import com.example.demo.entity.Homework;
import com.example.demo.entity.Params;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class HomeworkService {

    @Resource
    private HomeworkDao homeworkDao;
    public PageInfo<Homework> findBySearch(Params params) {
        //开启分页查询
        PageHelper.startPage(params.getPageNum(),params.getPageSize());
        List<Homework> bySearch = homeworkDao.findBySearch(params);
        return PageInfo.of(bySearch);
    }
    public void add(Homework homework) {
        homeworkDao.insertSelective(homework);
    }
    public void update(Homework homework) {
        homeworkDao.updateByPrimaryKey(homework);
    }
    public void delete(Integer id) {
        homeworkDao.deleteByPrimaryKey(id);
    }
}
